package dome3;

/**
 * Created with IntelliJ IDEA.
 * Description: 双向链表测试代码
 * User: 王圆豪
 * Date: 2024-07-22
 * Time: 20:24
 */
public class Main {
    public static void main(String[] args) {
        System.out.println("========首插=======");
        LinkedList<Integer> a = new LinkedList<>();
        a.addFirst(1);
        a.addFirst(2);
        System.out.print("首插结果：");
        a.display();

        System.out.println("=======尾插========");
        a.addLast(3);
        a.addLast(4);
        System.out.print("尾插结果：");
        a.display();

        System.out.println("=======指定位置插入数据=======");
        a.addIndex(1,99);
        a.addIndex(0,65);
        System.out.print("插入结果：");
        a.display();

        System.out.println("=======是否含有指定元素=======");
        System.out.println("是否有99：" + a.contains(99));

        System.out.println("=======移除第一次出现的指定元素=======");
        a.remove(99);
        a.display();

        System.out.println("=======链表长度=======");
        System.out.println("链表长度：" + a.size());

        System.out.println("=======清空链表=======");
        a.clear();
        a.display();
    }
}
